<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%String ctx = request.getContextPath();%>
<title>corrent question</title>
</head>

<script>

	let currNum = Number(${CurrQueNum})
	let qid = 1

	$(document).ready(function(){
		if($("#editormd-id").val() !== undefined) {
			editormd("editormd-id", {
				syncScrolling: "single",
				path: "<%=ctx%>/js/lib/",
				saveHTMLToTextarea: true,
			})
		}
	});

	function getDiscussQuestion(studentNumber) {

		let examName = $("#exam").find("option:selected").text();
		let qid = $("#discuss—num").val();

		$.ajax(
				{
					type:"GET",
					url: '<%=ctx%>/correct?act=getDiscussQuestion',
					dataType: "json",
					data: {
						"StudentNumber": studentNumber,
						"ExamName": examName,
						"QueNum": qid,
					},
					success: function(data, status) {
						$('#answer textarea[name="markdown-text"]').html(data.content)
					},
					error: function(req, status, msg) {
						alert(msg);
					}
				}
		)
	}

	function uploadScore(score) {
	}

</script>

<body>

<div id="list" class="col-md-10 col-xs-12">
	<h3>简答题批改</h3>
	<hr>

	<div class="fiter col-md-10 col-xs-12">
		<br>
		<form action="" class="form-horizontal form-inline">
			<select class="form-control" id="exam">
				<c:forEach items="${ExamList}" var="Exam" varStatus="s">
					<td>${s.index + 1}</td>
					<option value="${Exam.id}">${Exam.name}</option>
				</c:forEach>
			</select>
		</form>
	</div>
	<p/>
	<p/>
	<div class="fiter col-md-10 col-xs-12">
		<form action="" class="form-horizontal form-inline">
			<input class="form-control" type="text" id="discuss—num" placeholder="题号">
		</form>
	</div>
	<p/>
	<p/>

	<div class="fiter col-md-10 col-xs-12">
		<c:forEach items="${UserList}" var="User" varStatus="s">
			<button type="button" class="btn" onclick="getDiscussQuestion(${User.number})">${User.username}</button>
		</c:forEach>
	</div>
</div>

	<div class="container">

		<div class="row" id="answer">
			<textarea name="markdown-text" rows="40" cols="120"></textarea>
		</div>

	</div>
</body>
</html>